home *** CD-ROM | disk | FTP | other *** search
- Path: zilker.net!usenet
- From: gregor@di3270.com (Greg Rickard)
- Newsgroups: comp.lang.c++
- Subject: Re: private base class vs. private member object
- Date: 12 Mar 1996 18:45:04 GMT
- Organization: Data Interface Systems Corporation
- Message-ID: <4i4gng$5v4@hackberry.zilker.net>
- Reply-To: di@di3270.com
- NNTP-Posting-Host: dp9.zilker.net
- X-Newsreader: WinVN 0.91.6
-
- Certainly to be able to access the protected methods of another class,
- that class must be incorporated as a base class.
- Now what about the case where a service MUST be incorporated as a private
- member object (i.e., CANNOT be incorporated as a base class)?
-
- >gregor@di3270.com (Greg Rickard) wrote:
- >>In Cargill's C++ Programming Style, exercise 3.1 asks the reader to
- >>"create a class that obtains the services of another class that must be
- >>incorporated as a private base class. Second, create a class in which a
- >>service must be incorporated as a private member object".
-
- In article <4hrl32$4b3@newsgate.dircon.co.uk>, Rob and Sylvia Worsnop
- <gillesp@dircon.co.uk> says:
- >
- >I'm not sure quite what you mean here so there is a risk that I'll
- >be answering a question you've not even asked! Anyway , here goes..
- >
- >If you are asking when to use private base classes and when to use a
- >private member object, the answer is that you can use private member
- >object only when you can do everything you want with that object's
- >public interface.
- >If you want to access protected methods use private inheritance.
- >Some people just use private inheritance anyway because the code
- >is often cleaner.
- >Whether you use private member objects or private inheritance doesn't
- >matter a great deal. The really important thing is not to confuse
- >public inheritance and private inheritance.
- >
- >Rob.
-